import React, {Component} from 'react';
import LeaveNote from "../pages/LeaveNote";
import {LeftOutlined} from '@ant-design/icons';
import Settings from "../pages/Settings";

class LeaveNoteLayout extends Component {
    state = {
        type: "info",
    }

    componentDidMount() {
        let username = localStorage.getItem("username");
        let className = localStorage.getItem("classname");
        let phone = localStorage.getItem("phone");
        let id = localStorage.getItem("id");
        console.log(username, className, phone, id);
        if (username === null || className === null || phone === null || id === null){
            this.setState({ type: "setting" })
        }
    }

    render() {
        let {type} = this.state;
        console.log("type: ", type);
        if (type === "setting"){
            return <Settings onReturn = {()=>{ this.setState({type: "info"}) }}/>
        }else {
            return <div>
                <div style={{
                    fontSize: "20px",
                    lineHeight: "50px",
                    textAlign: "center",
                    borderBottom: "1px solid lightgray",
                }}>
                    <LeftOutlined
                        style={{ float: "left", margin: "12px" }}
                        onClick={()=>{
                            console.log("LeftOutlined: onClick: ")
                            this.setState({ type: "setting" })
                        }}
                    />
                    <span style={{ marginLeft: "-24px"}}>请假</span>
                </div>
                <LeaveNote/>
            </div>
        }
    }
}

export default LeaveNoteLayout;
